import logging
from time import sleep

import allure
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait

from ding.LitemallPrac.page_objects.base_page import BasePage

class DeletePage(BasePage):
    _MENU_PPRODUCT_DELETE=(By.XPATH,"//*[@id='app']/div/div[2]/section/div/div[2]/div[3]/table/tbody/tr[1]/td[7]/div/button[2]/span")
    #_MENU_PRODUCT_LAUNCH = (By.XPATH,"//span[contains(text(),'商品评论')]")
    _COMMENT_RESULT = (By.XPATH, "/html/body/div[2]/div/div[1]/p")

    #点击菜单
    with allure.step("评论删除"):
        def comment_delete(self):
            # 点击删除按钮
            logging.info("点击删除按钮")
            self.do_click(*self._MENU_PPRODUCT_DELETE)
            sleep(1)
            # 定位到toast弹框
            logging.info("点位到弹框")
            wait = WebDriverWait(self.driver, 1)
            self.driver.switch_to.default_content()
            element = wait.until(EC.visibility_of_element_located(self._COMMENT_RESULT))
            return element.text
            # el = self.driver.find_element(By.XPATH,'')



